from selenium.webdriver.common.by import By
from yklx.lx2.Base import Base
from time import sleep

#页面类
class Page(Base):
    #数码影视
    proce=(By.XPATH,'/html/body/div[3]/div/ul/li[1]/a')

    #商品定位
    shop=(By.CLASS_NAME,'f-img')

    #库存加一
    cangku=(By.XPATH,'//*[@id="digital-counter-new"]/div[1]/a[2]/i')

    #定位购买
    buy=(By.PARTIAL_LINK_TEXT,'立即购买')

    def search(self):
        #点击热销产品
        self.click(self.proce)
        sleep(5)

        #点击商品
        self.click(self.shop)
        sleep(5)

        #切换窗口
        self.new_window()
        sleep(2)

        #库存加一
        self.click(self.cangku)
        sleep(2)

        #点击立即购买
        self.click(self.buy)
        sleep(2)

    #逻辑
    def test_01_luoji(self):
        self.open_url('https://music.163.com/store/product/')
        self.search()
        sleep(5)